# -*- coding: utf-8 -*-
from utils.operators.spark_submit import SparkSubmitOperator
from datetime import timedelta

from jms.dim import jms_dim__dim_sys_network_detail_dt
from jms.dwd.dwd_route_taking_detail_dt import jms_dwd__dwd_route_taking_detail_dt
from jms.dws.dws_actual_aging_sign_dt import jms_dws__dws_actual_aging_sign_dt

jms_dwd__dwd_route_plan_sign_detail_dt = SparkSubmitOperator(
    task_id='jms_dwd__dwd_route_plan_sign_detail_dt',
    email=['suning@jtexpress.com','yl_bigdata@yl-scm.com'],
    name='jms_dwd__dwd_route_plan_sign_detail_dt_{{ execution_date | date_add(1) | cst_ds }}',
    pool_slots=5,
    driver_memory='4G' , 
    driver_cores=2 , 
    executor_memory='3G' , 
    executor_cores=4 , 
    num_executors=17 , 
    conf={'spark.dynamicAllocation.enabled': 'true',  # 动态资源开启
          'spark.shuffle.service.enabled': 'true',  # 动态资源 Shuffle 服务开启
        'spark.dynamicAllocation.maxExecutors'             : 20 , 
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 180,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.shuffle.partitions': 600,
        'spark.executor.memoryOverhead'             : '2G' , 
          'spark.core.connection.ack.wait.timeout': 300,
          'spark.default.parallelism': 600,
          'spark.locality.wait': 60,
          },
    jars='hdfs:///scheduler/jms/spark/chk/report/waybill_route_data/common-1.0-SNAPSHOT.jar',  # 依赖 jar 包
    java_class='com.yunlu.bigdata.jobs.report.RoutePlanSignDetailData',  # spark 主类
    application='hdfs:///scheduler/jms/spark/chk/report/waybill_route_data/original-jobs-1.0-SNAPSHOT.jar',
    # spark jar 包
    application_args=['{{ execution_date  | date_add(1)| cst_ds }}'],  # 参数dt 跑数据当天
    execution_timeout=timedelta(minutes=30),
)

# 设置依赖
jms_dwd__dwd_route_plan_sign_detail_dt << [
    jms_dim__dim_sys_network_detail_dt,
    jms_dwd__dwd_route_taking_detail_dt,
    jms_dws__dws_actual_aging_sign_dt
]
